package com.joe.learn.jvm;

import ch.qos.logback.core.util.FileUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Date;

@Data
@AllArgsConstructor
@ToString
public class JobBean implements Serializable {
    private static final Logger loggerA = LoggerFactory.getLogger("com.joe.learn.jvm.JobA");
    private static final Logger loggerB = LoggerFactory.getLogger("com.joe.learn.jvm.JobB");
    private static final Logger loggerC = LoggerFactory.getLogger("com.joe.learn.jvm.JobC");

    private Integer id;

    private String name;

    private String num;

    private String target;

    private String desc;

    private int[] temp;


    public void toLogA() {
        loggerA.info("A:" + this.toString());
    }

    public void toLogB() {
        loggerB.info("B:" + this.toString());
    }

    public void toLogC() {
        loggerC.info("C:" + this.toString());
    }


    public void writeFile(File file) {
        try {
            FileUtils.writeLines(file, StandardCharsets.UTF_8.toString(), Arrays.asList(new Date().toString() + this.toString()),true);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
